package com.prestamomo.vil.ppa.pmvilmedium.pmvilarm.pmlocation;

import android.text.TextUtils;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class PmvilLocInfoMd {

    public static JSONObject getInfoPmvilLoaction(){
        JSONObject locationPmvilObj = new JSONObject();
        JSONObject gpsPmvilObj = new JSONObject();
        try {
            gpsPmvilObj.put("jsballwer",PmvilOpenLocationMd.locationPmvilLat == 0?-1:PmvilOpenLocationMd.locationPmvilLat);//--latitude
            gpsPmvilObj.put("irwkcfjne", PmvilOpenLocationMd.locationPmvilLot == 0?-1:PmvilOpenLocationMd.locationPmvilLot);//--longitude
            locationPmvilObj.put("urnkj", gpsPmvilObj);//gps--gps
            if (PmvilOpenLocationMd.locationPmvilAddress == null) {
                locationPmvilObj.put("bfasfixs", "");//--gps_address_province
                locationPmvilObj.put("kfojlz", "");//--gps_address_city
                locationPmvilObj.put("lrpstei", "");//（）--gps_address_street
            }else {
                List<String> pmvilGpsList = new ArrayList<>();
                pmvilGpsList.add(PmvilOpenLocationMd.locationPmvilAddress.getAdminArea());
                pmvilGpsList.add(PmvilOpenLocationMd.locationPmvilAddress.getLocality());
                pmvilGpsList.add(PmvilOpenLocationMd.locationPmvilAddress.getThoroughfare());
                for (int i = 0; i < pmvilGpsList.size(); i++) {
                    if (i == 0) {
                        locationPmvilObj.put("bfasfixs", TextUtils.isEmpty(pmvilGpsList.get(i)) ? "" : pmvilGpsList.get(i));//--gps_address_province
                    } else if (i == 1) {
                        locationPmvilObj.put("kfojlz", TextUtils.isEmpty(pmvilGpsList.get(i)) ? "" : pmvilGpsList.get(i));//--gps_address_city
                    } else if (i == 2) {
                        if (TextUtils.isEmpty(pmvilGpsList.get(i))) {
                            locationPmvilObj.put("lrpstei", "");//（）--gps_address_street
                        } else {
                            locationPmvilObj.put("lrpstei", pmvilGpsList.get(i));//（）--gps_address_street
                        }
                    }
                }
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return locationPmvilObj;
    }
}
